const utils = {
  toast(title = '数据加载失败...') {
    wx.showToast({
      title,
      mask: true,
      icon: 'none',
    })
  },
  formatDateToString(date) {
    if (!(date instanceof Date)) {
      date = new Date(date)
    }
    const YYYY = date.getFullYear()
    const MM = (date.getMonth() + 1 + '').padStart(2, '0')
    const dd = (date.getDate() + '').padStart(2, '0')
    return `${YYYY}-${MM}-${dd}`
  },
}

wx.utils = utils

export default utils
